    var rTotal = 0;
	var resultArray;
	var account = $api.getStorage('account');
	var member2 = $api.getStorage('member2');
	var compounds = member2.compounds;
	var unitName = member2.unitName;
	var roomNumber = member2.roomNumber;
	var zycode = member2.zycode;

	apiready = function(){
		
		$api.byId('compounds').innerHTML = compounds + " " + unitName + " " + roomNumber + "号";
				
		api.showProgress({
	        title: '加载中...',
	        modal: false
	    });
	    
	    var getUrl = serviceUrl+"/app/propertyfees?account=" + account;
		api.ajax({
	        url: getUrl,
	        method: 'get',
	        cache: false,
	        timeout: 20,
	        headers: {
	            "Content-type": "application/json;charset=UTF-8"
	        }
	    }, function (ret, err) {
	    	 if (ret) {
	    	    
	    	    if(ret.length>0){
	    	       resultArray=ret;
	    	       updateUI(ret);
	    	       $api.css($api.byId('jiaofei'),'display:block');
	    	    }else{
	    	       
	    	       $api.byId('feellist').html = '<div class="am-u-sm-12"  style="padding:5px;text-align:center;">亲，您暂无需缴费用哦...</div>';
	    	    
	    	       $api.css($api.byId('jiaofei'),'display:none');
	    	    }
	        	
	        } else {
	            api.alert({msg: err.msg});
	        }
	        api.hideProgress();
	    });
	};
	
	
	function updateUI(list) {
		
    	var yearmonth = "";
    	var result = list;
    	var resultT = list;
    	
    	
    	
    	var ahtml="";
    	if (result.length > 0) {
    	
			for (var i in result) {
				
				rTotal+= Number(result[i].qsaccount);
				
				if (result[i].yearmonth != yearmonth) {
				
					ahtml += '<div class="am-u-sm-12" style="background:#efefef;border-radius:5px;padding:2px;color:red;">';
					ahtml += result[i].yearmonth;
					ahtml += '</div>';
					
					for (var j in resultT) {
					
						if (result[i].yearmonth == resultT[j].yearmonth) {
						
							ahtml += '<div class="am-u-sm-12" style="padding:8px;">';
							
							ahtml += '<div class="am-u-sm-6" style="padding:0px;">';
							ahtml += result[j].name;
							ahtml += '</div>';
							
							ahtml += '<div class="am-u-sm-6" style="padding:0px;">';
							ahtml += '￥'+result[j].qsaccount;
							ahtml += '</div>';
							
							
							ahtml += '</div>';
						}
					}
					
					yearmonth = result[i].yearmonth;
				}
				
			}
			
		} else {
			
			ahtml += '<div class="am-u-sm-12" style="margin:0px;background: white;padding:10px;text-align:center;">亲，您还没账单数据呢...</div>';
		}
		
		$api.byId("feellist").innerHTML = ahtml;
		$api.text($api.byId('total'),rTotal.toFixed(2));
		
		
	}
	
	
	//缴费
	function submit() {
		var item =[];
		rTotal = rTotal.toFixed(2);
		
		for (var i = 0; i < resultArray.length; i++) {
			var yearmonth = resultArray[i].yearmonth;
			var name = resultArray[i].name;
			var qsaccount = resultArray[i].qsaccount;
			item.push({'yearmonth':yearmonth, 'name':name, 'cost':qsaccount, 'num':1, 'total':qsaccount});
		}
		
		var data={
	        'rTotal' :rTotal,
	    	'total' : rTotal,
	    	'account' : account,
	    	'zycode' :zycode,
	    	'compound' :compounds + " " + unitName + " " + roomNumber + "号",
	    	'payType' :'支付宝',
	    	'item':item,
		};
		
//		alert(JSON.stringify(data));

		
		do_ajax('/app/propertyorder/add2','post',data,function(respose,err){
		    api.hideProgress();

			if (respose.resultCode == "0") {
	                api.hideProgress();
					var orderinfo= {
						orderNo: respose.orderNo,
						total:rTotal,
						payType:'支付宝',
					};
					
				   api.openWin({
				        name: 'pay',
				        url: "../pay.html",
				        pageParam: {orderinfo:orderinfo},
				       }
				   );
				   
		   }else{
		      alert(respose.datas);
		   }
		   
		});
		
	
	}
	

